home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
- #include "resource.h"
-
- CBlasterApp theApp;
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX);
- //}}AFX_VIRTUAL
-
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CBlasterApp, CWinApp)
- //{{AFX_MSG_MAP(CBlasterApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- END_MESSAGE_MAP()
-
- CBlasterApp::CBlasterApp()
- {
- }
-
- BOOL CBlasterApp::InitInstance()
- {
- // Display splash screen
-
- CDialog splash;
- splash.Create(IDD_SPLASH_SCREEN);
- splash.SetWindowPos(&CWnd::wndTop, 0, 0, 320, 240, SWP_NOMOVE);
- splash.RedrawWindow();
-
- // Initialize windows app
-
- srand(time(0));
-
- Enable3dControls();
-
- SetRegistryKey(_T("3.14 Software"));
-
- LoadStdProfileSettings();
-
- read_profile();
-
- // Load game data
-
- init_directdraw_inawin();
- init_directsound();
- init_directinput();
- init_fonts();
- init_game_data();
-
- // Register the application's document templates. Document templates
- // serve as the connection between documents, frame windows and views.
-
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(CBlasterDoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(CBlasterView));
- AddDocTemplate(pDocTemplate);
-
- // Make .bdl belong to our application
-
- RegisterShellFileTypes();
-
- // Parse command line for standard shell commands, DDE, file open
-
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
-
- // Dispatch commands specified on the command line
-
- if (!ProcessShellCommand(cmdInfo))
- return FALSE;
-
- // Destroy splash screen
-
- splash.DestroyWindow();
-
- // The one and only window has been initialized, so show and update it.
-
- CMainFrame::ResizeToFitGameArea();
- m_pMainWnd->ShowWindow(SW_SHOW);
- m_pMainWnd->UpdateWindow();
-
- // Accept files
-
- m_pMainWnd->DragAcceptFiles();
-
- // Initialize things we need a window for
-
- init_directsound_primarybuffer();
- init_music();
- init_keyboard();
- init_joystick();
-
- // Quickstart
-
- mainwindow->PostMessage(WM_COMMAND, ID_QUICKSTART, 0);
-
- // Start message pump
-
- return TRUE;
- }
-
- int CBlasterApp::ExitInstance()
- {
- // Kill game
-
- deinit_game();
-
- // Save state of the program
-
- write_profile();
-
- // Call base class
-
- return CWinApp::ExitInstance();
- }
-
- void CBlasterApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
-
- void deinit_game()
- {
- deinit_game_loop();
- deinit_keyboard();
- deinit_joystick();
- deinit_music();
- deinit_game_data();
- deinit_fonts();
- deinit_directsound();
- deinit_directinput();
- deinit_directdraw();
- }
-